package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellOption;

import java.util.List;

@SpringBootApplication
@ShellComponent
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    // 简单的无参数问候命令
    @ShellMethod("Prints a greeting message")
    public String greet() {
        return "Hello, Spring Shell!";
    }

    // 带有两个整数参数的加法命令
    @ShellMethod("Adds two numbers")
    public int add(@ShellOption(defaultValue = "0") int num1, @ShellOption(defaultValue = "0") int num2) {
        return num1 + num2;
    }

    // 接收字符串列表参数并拼接显示的命令
    @ShellMethod("Concatenates the given strings")
    public String concatenate(@ShellOption(defaultValue = "") List<String> strings) {
        return String.join(" ", strings);
    }

}
